var actor_unsigned_vsp, actor_modifier, actor_ground;
actor_dead = (actor_hp[0] <= 0) and (actor_hp[1] > 0);
actor_modifier = instance_place(x,y,obj_modifier);
if (actor_modifier > 0)
{
    switch (actor_modifier.modifier_kind)
    {
        case 0:
        actor_onwater = true;
        break;
        case 1:
        actor_onwater = true;
        actor_vsp = 8;
        break;
    }
}
else
{
    actor_onwater = false;
}
if (global.control == 1)
{
    if (actor_free == true)
    {
        actor_unsigned_vsp = min(ceil(abs(actor_vsp)),16);
        var actor_ycollision, actor_xcollision;
        repeat (actor_unsigned_vsp)
        {
            actor_ycollision = instance_place(x,y + sign(actor_vsp),obj_solid);
            if (actor_ycollision <= 0)
            {
                y += (sign(actor_vsp) * (30/room_speed));
            }
            else
            {
                actor_collision = actor_ycollision;
                actor_vsp = actor_collision.actor_vsp * (actor_collision.y < y);
            }
        }
        
        repeat (min(ceil(abs(actor_hsp)),16))
        {
            actor_xcollision = instance_place(x + sign(actor_hsp),y,obj_solid);
            if (actor_xcollision <= 0)
            {
                x += (sign(actor_hsp) * (30/room_speed));
                actor_hsp = max(abs(actor_hsp) - (actor_f),0) * (sign(actor_hsp));
            }
            else
            {
                actor_collision = actor_xcollision;
                if (actor_collision.actor_free == true) && (actor_collision.actor_g == global.g)
                {
                    actor_collision.actor_hsp += actor_hsp_impulse + (actor_hsp * (actor_hsp_impulse == 0));
                }
                actor_hsp = 0;
            }
        }
        
        actor_ground = instance_place(x,y + actor_g,obj_solid);
        if (actor_ground > 0) xor (actor_onfakeground == true)
        {
        actor_onground = true;
            if (sign(actor_vsp) == 0) or (sign(actor_vsp) == sign(actor_g)) or (actor_onfakeground == false)
            {
                actor_collision = actor_ground;
            }
        }
        else
        {
            actor_onground = false;
            actor_vsp += (actor_g  * (30/room_speed));
            actor_collision = -4;
        }
        if (actor_collision > 0)
        {
            if (instance_place(x,y + actor_g,obj_solid) == actor_collision) && (actor_collision.y > y)
            {
                actor_vsp = actor_collision.actor_vsp;
                if (place_meeting(x + actor_collision.actor_hsp + actor_hsp_impulse,y, obj_actor) == false)
                {
                    actor_hsp = actor_collision.actor_hsp + actor_hsp_impulse;
                }
            }
        }
        actor_vsp_impulse = 0;
        actor_hsp_impulse = 0;
        actor_g = global.g;
        actor_f = global.f;
    }
    else
    {
        x += (actor_hsp * (30 / room_speed));
        y += (actor_vsp * (30 / room_speed));
    }
}
